<%@page import="java.util.HashMap" %>
<%@page import="java.util.LinkedHashMap" %>
<%@page import="java.util.Iterator" %>
<%@ include file="header.jsp"%>
	<script>
		function insertPreference(r) {
			var i = r.parentNode.parentNode.rowIndex;
			var tableID = r.parentNode.parentNode.parentNode.parentNode.id;
			var row = document.getElementById(tableID).rows[i];
			var cells = row.cells;
	
			var mid = cells[0].innerHTML;
			var title = cells[1].innerHTML;
			var value = cells[2].getElementsByTagName("input")[0].checked ? 'true' : 'false';
			
			var uid = FB.getSession().uid;
			var param = "alg=" + encodeURIComponent(tableID) + "&uid=" + encodeURIComponent(uid) + "&mid=" + encodeURIComponent(mid) + "&vote=" + encodeURIComponent(value);
			sendRequest("/LaSeC/Survey", param, AJAXresult, "post");
		}
	</script>
	<div id = "body">
		<div class = "inner">
			<%
				HashMap<Integer, String> svdmovie = (LinkedHashMap<Integer, String>) request.getAttribute("svdmovie");
				HashMap<Integer, String> ssvdmovie = (LinkedHashMap<Integer, String>) request.getAttribute("ssvdmovie");
				HashMap<Integer, String> scsvdmovie = (LinkedHashMap<Integer, String>) request.getAttribute("scsvdmovie");
			
				Iterator<Integer> iter;
				int nCount = 0;
			%>	
			<p><a>SVD-Based</a>
			<table id = "0" border = "1">
			<%
				if (svdmovie != null) {
					iter  = svdmovie.keySet().iterator();
					while(iter.hasNext()) {
						nCount = iter.next();
					%>
						<tr>
							<td><%= nCount %></td>
							<td><%= svdmovie.get(nCount) %></td>
							<td>
								<input type="radio" name=<%= nCount %> value="true" onclick="return insertPreference(this)"/>YES
								<input type="radio" name=<%= nCount %> value="false" onclick="return insertPreference(this)"/>NO
							</td>
						</tr>
					<%	
					}
				}
			%>
			</table>
			</p>
			<p><a>Similarity SVD-Based</a>
			<table id = "1" border = "1">
			<%
				
				if (ssvdmovie != null) {
					iter = ssvdmovie.keySet().iterator();
					while (iter.hasNext()) {
						nCount = iter.next();
					%>
						<tr>
							<td><%= nCount %></td>
							<td><%= ssvdmovie.get(nCount) %></td>
							<td>
								<input type="radio" name=<%= nCount %> value="true" onclick="return insertPreference(this)"/>YES
								<input type="radio" name=<%= nCount %> value="false" onclick="return insertPreference(this)"/>NO
							</td>
						</tr>
					<%
					}
				}
			%>
			</table>
			</p>
			
			<p><a>Similarity + Commonality SVD-Based</a>
			<table id = "2" border = "1">
			<%
				if (scsvdmovie != null) {
					iter = scsvdmovie.keySet().iterator();
					while (iter.hasNext()) {
						nCount = iter.next();
					%>
						<tr>
							<td><%= nCount %></td>
							<td><%= scsvdmovie.get(nCount) %></td>
							<td>
								<input type="radio" name=<%= nCount %> value="true" onclick="return insertPreference(this)"/>YES
								<input type="radio" name=<%= nCount %> value="false" onclick="return insertPreference(this)"/>NO
							</td>
						</tr>
					<%
					}
				}
			%>
			<%
				svdmovie = null;
				ssvdmovie = null;
				scsvdmovie = null;
			%>
			</table>
			</p>
		</div>
	</div>
<%@ include file="footer.jsp"%>